<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="container"></div>
  <script src="jslib/mustache.js"></script>
  <script>
    var data = {
      arr: [
        { "name": "小明", "age": 12, "sex": "男", hobbies: ['看书', '游泳'] },
        { "name": "小红", "age": 11, "sex": "女", hobbies: ['看书', '写代码', '游泳'] },
        { "name": "小强", "age": 13, "sex": "男", hobbies: ['看书'] }
      ]
    }

    var templateStr = `
      <ul>
        {{#arr}}
          <li>
            {{name}}的爱好是：
            <ol>
              {{#hobbies}}
                <li>
                  {{.}}
                </li>
              {{/hobbies}}
            </ol>
          </li>  
        {{/arr}}  
      </ul>
    `
    var domStr = Mustache.render(templateStr, data)
    var container = document.getElementById('container')
    
    container.innerHTML = domStr
  </script>
</body>
</html>